<template>
  <div>
    <el-select v-model="values" multiple placeholder="请选择" @change="change">
    <el-option
      v-for="item in options"
      :key="item.id"
      :label="item.name"
      :value="item.id">
    </el-option>
  </el-select>
  </div>
</template>
<script>
  import Vue from 'vue'
  import * as service from "@/api/crud.base";
  import TreeUtil from '@/libs/tree'
  export default {
    props:{
      selected:{
        type:Array
      }
    },
    data() {
      return {
        options: [],
        values:[]
      }
    },
    watch:{
      selected:function(newValue,oldValue){
        this.values=this.selected;
      }
    },
    methods: {
      loadRoles() {
        service.list('/roles').then(res => {
          this.options = res;
        });
      },
      change(data){
        this.$emit('input',data);
      }
    },
    mounted() {
      this.loadRoles();
    }
  }
</script>
